package com.seeyon.bugfixtools.custom.datasource.dto;

import com.seeyon.bugfixtools.custom.datasource.manager.DBTypeEnum;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * @author cans
 * @date 2024/5/3
 **/
@Getter
@Setter
public class DatasourceDto implements Serializable {

    String type;
    String schema;
    String host;
    String port;
    String username;
    String password;

    public String getUrl() {
        switch (DBTypeEnum.valueOf(this.type)) {
            case Oracle:
                return String.format("jdbc:oracle:thin:@//%s:%s/%s", host, port, schema);
            case SqlServer:
                return String.format("jdbc:sqlserver://%s:%s;databaseName=%s", host, port, schema);
            default:
                return String.format("jdbc:mysql://%s:%s/%s", host, port, schema);
        }
    }
}
